package com.qiangesoft.bootcodegen.controller;

import com.qiangesoft.bootcodegen.entity.BcgColumnMap;
import com.qiangesoft.bootcodegen.framework.log.Log;
import com.qiangesoft.bootcodegen.pojo.dto.BcgColumnMapDTO;
import com.qiangesoft.bootcodegen.pojo.query.BcgColumnMapQuery;
import com.qiangesoft.bootcodegen.pojo.query.PageQuery;
import com.qiangesoft.bootcodegen.pojo.vo.PageResultVO;
import com.qiangesoft.bootcodegen.service.IBcgColumnMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 字段类型映射 前端控制器
 * </p>
 *
 * @author qiangesoft
 * @date 2024-04-01
 */
@Api(tags = "字段类型映射")
@RequiredArgsConstructor
@RestController
@RequestMapping("/columnMap")
public class BcgColumnMapController {

    private final IBcgColumnMapService columnMapService;

    @Log(module = "字段类型映射", operationName = "新增类型映射")
    @ApiOperation(value = "新增类型映射")
    @PostMapping
    public void saveColumnMap(@RequestBody @Validated BcgColumnMapDTO columnMapDTO) {
        columnMapService.saveColumnMap(columnMapDTO);
    }

    @Log(module = "字段类型映射", operationName = "删除类型映射")
    @ApiOperation(value = "删除类型映射")
    @DeleteMapping("/{ids}")
    public void removeColumnMap(@PathVariable List<Long> ids) {
        columnMapService.removeColumnMap(ids);
    }

    @Log(module = "字段类型映射", operationName = "修改类型映射")
    @ApiOperation(value = "修改类型映射")
    @PutMapping("/{id}")
    public void updateColumnMap(@PathVariable Long id, @RequestBody @Validated BcgColumnMapDTO columnMapDTO) {
        columnMapService.updateColumnMap(id, columnMapDTO);
    }

    @Log(module = "字段类型映射", operationName = "查询类型映射")
    @ApiOperation(value = "查询类型映射")
    @GetMapping
    public PageResultVO<BcgColumnMap> listColumnMap(@Validated PageQuery pageQuery, BcgColumnMapQuery columnMapQuery) {
        return columnMapService.listColumnMap(pageQuery, columnMapQuery);
    }
}
